#include "EpilChunkInterpreter.h"
#include "EpilStatementInterpreter.h"
#include "EpilInterpreter.h"


EpilChunkInterpreter::EpilChunkInterpreter( EpilInterpreter * interpreter )
: EpilInterpreterBase( interpreter )
, m_exitReason( ECER_Normal )
, m_exitLocation( EpilLexLocation::InvalidLocation )
{
}


void EpilChunkInterpreter::Run( const EpilChunkCode * code )
{
	const EpilStatementCodeList & statements = code->GetStatements();
	for( EpilStatementCodeList::const_iterator it = statements.begin(); it != statements.end(); ++it )
	{
		EpilStatementInterpreter si( this->GetInterpreter() );
		si.Run( *it );
		m_exitReason = si.GetExitReason();
		m_exitLocation = si.GetExitLocation();
		if( m_exitReason != ECER_Normal )
		{
			return;
		}
	}
}